package homework.Demo2;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Random;

public class Test {
    public static void main(String[] args) {
        HashSet<Ball> redBalls = new HashSet<>();
        HashSet<Ball> blueBalls = new HashSet<>();
        Random random = new Random();
        //生成6个红色球
        while (redBalls.size() < 6) {
            Ball b = new Ball("红色",random.nextInt(33)+1);
            redBalls.add(b);
        }

        //生成一个蓝色球
        Ball ball=new Ball("蓝色",random.nextInt(16)+1);
        blueBalls.add(ball);

        ArrayList<Ball> redBallList = new ArrayList<>(redBalls);
        redBallList.sort((b1,b2)->b1.getNumber()-b2.getNumber());
        System.out.println("双色球中奖号码:");
        System.out.println("红球是: ");
        redBallList.forEach(System.out::println);
        System.out.println();
        System.out.println("蓝球是: ");
        System.out.println(blueBalls);
    }
}
